package com.ruoyi.his.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.his.mapper.DoctorMapper;
import com.ruoyi.his.domain.Doctor;
import com.ruoyi.his.service.IDoctorService;

/**
 * 医生信息Service业务层处理
 * 
 * @author hzr
 * @date 2024-10-16
 */
@Service
public class DoctorServiceImpl implements IDoctorService 
{
    @Autowired
    private DoctorMapper doctorMapper;

    /**
     * 查询医生信息
     * 
     * @param id 医生信息主键
     * @return 医生信息
     */
    @Override
    public Doctor selectDoctorById(Long id)
    {
        return doctorMapper.selectDoctorById(id);
    }

    /**
     * 查询医生信息列表
     * 
     * @param doctor 医生信息
     * @return 医生信息
     */
    @Override
    public List<Doctor> selectDoctorList(Doctor doctor)
    {
        return doctorMapper.selectDoctorList(doctor);
    }

    /**
     * 新增医生信息
     * 
     * @param doctor 医生信息
     * @return 结果
     */
    @Override
    public int insertDoctor(Doctor doctor)
    {
        return doctorMapper.insertDoctor(doctor);
    }

    /**
     * 修改医生信息
     * 
     * @param doctor 医生信息
     * @return 结果
     */
    @Override
    public int updateDoctor(Doctor doctor)
    {
        return doctorMapper.updateDoctor(doctor);
    }

    /**
     * 批量删除医生信息
     * 
     * @param ids 需要删除的医生信息主键
     * @return 结果
     */
    @Override
    public int deleteDoctorByIds(Long[] ids)
    {
        return doctorMapper.deleteDoctorByIds(ids);
    }

    /**
     * 删除医生信息信息
     * 
     * @param id 医生信息主键
     * @return 结果
     */
    @Override
    public int deleteDoctorById(Long id)
    {
        return doctorMapper.deleteDoctorById(id);
    }

    @Override
    public Map<String, Integer> getDoctorStatusCount() {
        Map<String, Integer> result = doctorMapper.selectDoctorStatusCount();

        // 确保数值是 Double 类型
        result.put("inService", (int) ((Number) result.get("inService")).doubleValue());
        result.put("onLeave", (int) ((Number) result.get("onLeave")).doubleValue());
        result.put("resigned", (int) ((Number) result.get("resigned")).doubleValue());

        return result;
    }
}


